<?php

/**
 * Controller_publish
 * 
 */

class Controller_publish extends MyApp {

	public function __construct()
	{

		parent::__construct();


	}

	/** 首页 **/
	public function actionIndex()
	{

	}

	/** ajax添加 **/
	public function actionAddAjax()
	{
		$name = trim($this->get->name);
		if (empty($name)){
			exit();
		}

		// 查询是否存在
		$row = $this->db->fetchRow("SELECT * FROM `tbl_publish` WHERE publish_name='{$name}'");
		if (!empty($row)){
			echo $row['publish_id'];
		}else{
			$info = array(
			"publish_name" => $name,
			"status"        => 1,
			"create_time"   => date("Y-m-d H:i:s"),
			"update_time"   => "0000-00-00 00:00:00"
			);

			$this->db->do_insert("tbl_publish", $info);

			echo $this->db->insert_id();
		}
		exit();

	}

}

?>